# dictionaries 字典
mydict = {
    "a":"admin",
    "d":"dictionaries"
}

# 访问
print(mydict['d'])

# print(mydict['z'])
# KeyError: 'z'

# print(mydict.z)
# AttributeError: 'dict' object has no attribute 'z'

print(mydict.get('z'))
print(mydict.get('d'))


# 修改
print(mydict)
# application
mydict['a'] = 'application'
print(mydict)


# 添加
# "u":"undefined"
mydict["u"] = "undefined"
print(mydict)
# "j":"justification"
mydict["j"] = "justification"
print(mydict)



# 删除
# del mydict["j"]
# print(mydict)
# del mydict["u"]
# print(mydict)
# del mydict
# print("del mydict: ", mydict)

# mydict.clear()
# print("clear mydict: ",mydict)


# 遍历字典
for key in mydict.keys():
    print("mydict key:%s" % key)
for value in mydict.values():
    print("mydict value:%s" % value)
for key,value in mydict.items():
    print("mydict %s:%s" % (key,value))
for item in mydict.items():
    print(item)













